app.controller("cartCtrl",["$scope","$http","sc","$rootScope",function($scope,$http,sc,$rootScope){
	$scope.buy=sc.data;
	/*$scope.carData=JSON.parse(window.localStorage.car)*/
	$rootScope.flag=true;
	$scope.addGOOds=function(i,num){
			if(i.num){
				i.num+=num;
			}else{
				i.num=1;
			}
			/*if(window.localStorage.car){
				obj=JSON.parse(window.localStorage.car);
			}
			obj[i.id]=i;
			window.localStorage.setItem("car",JSON.stringify(obj));*/
			/*window.localStorage.setItem("numm",JSON.stringify(i.num));
			i.num=window.localStorage.numm;*/
			sc.addGs(i);
			if(i.num==0){
				sc.delGs(i);
			}
			$rootScope.num1+=num;
			if(i.state==true){
			$scope.doller+=num*(i.price);
			}
	
	}
	$scope.doller=sc.money($scope.buy);
	$scope.state=true;
	$scope.selectAll=function(){
			sc.selectAll($scope.state);
			if($scope.state==true){
			$scope.doller=sc.money($scope.buy);
			}else{
				$scope.doller=0;
			}

	}
	$scope.selectFn=function(i){
		$scope.state=sc.selectFn($scope.state);
		if(i.state==true){
		$scope.doller+=(i.num)*(i.price);
		}else{
		$scope.doller-=(i.num)*(i.price);			
		}
	}
	}
])